<template>
  <div>
    <el-table
      ref="customerTable"
      :data="tableData"
      stripe
      style="width: 100%"
      @selection-change="getSelectVal"
    >
      <el-table-column type="selection" width="55" align="center">
      </el-table-column>
      <el-table-column type="index" align="center"></el-table-column>
      <el-table-column prop="supplierName" label="供应商名称"></el-table-column>
      <el-table-column prop="contactsName" label="联系人"></el-table-column>
      <el-table-column prop="contactsTel" label="联系人手机"></el-table-column>
      <el-table-column prop="telPhone" label="电话"></el-table-column>
      <el-table-column prop="address" label="详细地址"></el-table-column>
      <el-table-column prop="brand" label="品牌类别"></el-table-column>
      <el-table-column prop="address" label="详细地址"></el-table-column>
      <el-table-column prop="email" label="邮箱"></el-table-column>
      <el-table-column prop="level" label="供应商等级">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.level === '0'" type="success">A</el-tag>
          <el-tag v-if="scope.row.level === '1'" type="info">B</el-tag>
          <el-tag v-if="scope.row.level === '2'" type="warning">C</el-tag>
          <el-tag v-if="scope.row.level === '3'" type="danger">D</el-tag>
        </template>
      </el-table-column>
      <el-table-column prop="type" label="供应商分类">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.type === '0'" type="success">A</el-tag>
          <el-tag v-if="scope.row.type === '1'" type="info">B</el-tag>
          <el-tag v-if="scope.row.type === '2'" type="warning">C</el-tag>
          <el-tag v-if="scope.row.type === '3'" type="danger">D</el-tag>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      class="pagination mt10"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="[10, 20, 30, 40]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
      background
    >
    </el-pagination>
  </div>
</template>

<script>
import { getSupplierData } from "@/api/base/data";
export default {
  data() {
    return {
      tableData: [],
      currentPage: 1, //当前页
      pageSize: 10, //每页条数
      total: 0,
    };
  },
  methods: {
    //分页器size
    handleSizeChange(val) {
      this.pageSize = val;
      this.getDataList();
    },
    //分页器当前页
    handleCurrentChange(val) {
      this.currentPage = val;
      this.getDataList();
    },
    getSelectVal(val) {
      // if (val.length) {
      this.$emit("update:visible", false);
      this.$emit("getSelectVal", val);
      // }
    },
    getDataList() {
      getSupplierData({
        page: this.currentPage,
        pageSize: this.pageSize,
      }).then((res) => {
        this.tableData = res.rows;
        this.total = res.total;
      });
    },
  },
  mounted() {
    this.getDataList();
  },
};
</script>

<style></style>
